package test_new;

import org.junit.*;

public class BubbleSortTest {
	@Test
	public void test_BubbleSort() {
		int[] array = {4, 6, 7, 1, 9, 2, 5, 3, 8};
		BubbleSort matrix = new BubbleSort(array, new NaturalOrderComparator());
		matrix.makeBubbleSort();
		Assert.assertArrayEquals(new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, matrix.getArray());
	}	

	@Test
	public void testRevert() {
		int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9};
		BubbleSort matrix = new BubbleSort(array, new NaturalOrderComparator());
		matrix.revert();
		Assert.assertArrayEquals(new int[]{9, 8, 7, 6, 5, 4, 3, 2, 1}, matrix.getArray());
	}

	@Test
	public void testRevertWithout9() {
		int[] array = {1, 2, 3, 4, 5, 6, 7, 8};
		BubbleSort matrix = new BubbleSort(array, new NaturalOrderComparator());
		matrix.revert();
		Assert.assertArrayEquals(new int[]{8, 7, 6, 5, 4, 3, 2, 1}, matrix.getArray());
	}
	

}


